// 皮肤列表
import sequelize from "../db/seq.js";
import { DataTypes } from "sequelize";
const Hero = sequelize.define("Hero", { name: DataTypes.STRING });
const skinList = sequelize.define("skinList", {
  skinId: {
    type: DataTypes.INTEGER,
    allowNull: false,
    primaryKey: true,
    autoIncrement: true,
  },
  skinName: {
    type: DataTypes.STRING,
    allowNull: false,
  },
  skinImg: {
    type: DataTypes.STRING,
    allowNull: false,
  },

  // 关联的英雄ID（外键）
  heroId: {
    type: DataTypes.INTEGER,
    allowNull: false,
    references: {
      model: Hero,
      key: "heroId",
    },
    onDelete: "CASCADE", // 明确设置级联删除
    onUpdate: "CASCADE", // 明确设置级联更新
  },
});
// 定义关联关系
skinList.belongsTo(Hero, { foreignKey: "heroId" });

// skinList.sync({ force: true });
export default skinList;
